package com.example.udptestdemo;

public class SyncLock {

	private  boolean mIsTimeout;
	
	public SyncLock(){
		
	}
	
	
	/**
	 * 阻塞线程  如果超时 返回 true  notify 返回 false
	 * @param timeout
	 * @return
	 */
	public boolean Wait(int timeout){
		synchronized (this) {
			mIsTimeout=true;
			try {
				this.wait(timeout);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		return mIsTimeout;
		
	}
	
	public void Notify(){
		synchronized(this){
			mIsTimeout=false;
			this.notify();
		}
	}
}
